
import 'package:flutter/cupertino.dart';
import 'package:flutter_deer/indent/iview/indent_list_iview.dart';
import 'package:flutter_deer/index/models/user_betting_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/net.dart';
import 'package:flutter_deer/res/constant.dart';
import 'package:oktoast/oktoast.dart';

class IndentListPagePresenter extends BasePagePresenter<IndentListIMvpView> {

  IndentListPagePresenter();

  @override
  void initState() {
  }

  Future<dynamic> getIndentList(int? index) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['status'] = index.toString();
      params['size'] = Constant.pageSize;
      params['current'] = 1;
      asyncRequestNetwork<BaseEntity<UserBettingPageEntity>>(Method.get,
        url: HttpApi.bettingList,
        queryParameters: params,
        onSuccess: (data) {
          view.setUserBettingPage(data!.data);
        },
        onError: (code,msg) {
        }
      );
    });
  }

  Future<dynamic> getMoreIndentList(int? index,int? pageNo) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['status'] = index.toString();
      params['size'] = Constant.pageSize;
      params['current'] = pageNo;
      asyncRequestNetwork<BaseEntity<UserBettingPageEntity>>(Method.get,
        url: HttpApi.bettingList,
        queryParameters: params,
        onSuccess: (data) {
          view.setUserBettingPage(data!.data);
        },
          onError: (code,msg) {

          }
      );
    });
  }

  // Future<dynamic> revokeBetting(int? id) async {
  //   return asyncRequestNetwork<OperatorBaseEntity>(Method.delete,
  //     url: HttpApi.revokeBetting.replaceAll('{id}', id.toString()),
  //     onSuccess: (data) {
  //       view.revokeBettingResult(data!.data);
  //     },
  //     onError: (code,msg){
  //
  //     }
  //   );
  // }


}